package com.h3c.nem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.h3c.nem.entity.TbCareEncourage;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface TbCareEncourageMapper extends BaseMapper<TbCareEncourage> {
    /**
     * 获取收到的鼓励信息（人 + 鼓励语句）
     *
     * @param userId
     * @return java.util.List<java.util.Map < java.lang.String, java.lang.Object>>
     * @author z22968
     * @date 2022-06-28 09:34
     */
    @Select("select saw.*,tci2.`created_time`, tci2.`type`,tci2.`statement` as encourageStatement from ( \n" +
            "   select tci.`old_worker_id`, tci.`type` ,tce.`statement`,tce.`created_time` from tb_care_encourage tce join tb_care_info tci on tce.care_info_id = tci.id where tce.ignore_flag!=1  and tce.new_worker_id = #{userId}\n" +
            ") tci2 \n" +
            "join sd_all_worker saw \n" +
            "on tci2.`old_worker_id` = saw.`worker_id` order by tci2.`created_time` desc"
    )
    List<Map<String, Object>> getReceiveEncourageList(String userId);
}
